import os.path

folders=['./symbide/src/execution',
         './symbide/src/parsing',
         './symbide/src/widgets',] 
#folders = ['./symbide/src']

def visit(glob_stat, dir, names):
    for i in names:
        p = os.path.join(dir, i)
        if not os.path.isfile(p) or not os.path.splitext(p)[1]=='.py':
            continue
        f = open(p)
        
        lines, blanklines, words, characters, comments = 0, 0, 0, 0, 0
        
        for line in f:
            lines+=1
            
            if not line.strip(' \t\n'):
                blanklines+=1
            if len(line.lstrip(' \t')) and line.lstrip(' \t')[0]=='#':
                comments+=1
            characters+=len(line)
            words+=len(line.split(None))
        
        glob_stat[p]=(lines, blanklines, comments, words, characters)

for f in folders:
    path = os.path.abspath(f)
    stat = {}
    os.path.walk(path, visit, stat)


lines, blanklines, words, characters, comments = 0, 0, 0, 0, 0
for i, j in stat.iteritems():
    lines+=j[0]
    blanklines+=j[1]
    comments+=j[2]
    words+=j[3]
    characters+=j[4]
    print os.path.basename(i), j


print 'files:', len(stat)
print 'lines:', lines
print 'comments', comments
print 'blanklines:', blanklines
print 'words:', words
print 'characters', characters